package com.punai.customer.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.punai.common.utils.DateUtils;
import com.punai.customer.domain.CusLinkSubpkConsumeAddress;
import com.punai.customer.mapper.CusLinkSubpkConsumeAddressMapper;
import com.punai.customer.service.ICusLinkSubpkConsumeAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 标准费用项材机耗量地区Service业务层处理
 *
 * @author zhx
 * @date 2023-02-02
 */
@Service
public class CusLinkSubpkConsumeAddressServiceImpl extends ServiceImpl<CusLinkSubpkConsumeAddressMapper,CusLinkSubpkConsumeAddress> implements ICusLinkSubpkConsumeAddressService
{
    @Autowired
    private CusLinkSubpkConsumeAddressMapper cusLinkSubpkConsumeAddressMapper;

    /**
     * 查询标准费用项材机耗量地区
     *
     * @param id 标准费用项材机耗量地区主键
     * @return 标准费用项材机耗量地区
     */
    @Override
    public CusLinkSubpkConsumeAddress selectCusLinkSubpkConsumeAddressById(String id)
    {
        return cusLinkSubpkConsumeAddressMapper.selectCusLinkSubpkConsumeAddressById(id);
    }

    /**
     * 查询标准费用项材机耗量地区列表
     *
     * @param cusLinkSubpkConsumeAddress 标准费用项材机耗量地区
     * @return 标准费用项材机耗量地区
     */
    @Override
    public List<CusLinkSubpkConsumeAddress> selectCusLinkSubpkConsumeAddressList(CusLinkSubpkConsumeAddress cusLinkSubpkConsumeAddress)
    {
        return cusLinkSubpkConsumeAddressMapper.selectCusLinkSubpkConsumeAddressList(cusLinkSubpkConsumeAddress);
    }

    /**
     * 新增标准费用项材机耗量地区
     *
     * @param cusLinkSubpkConsumeAddress 标准费用项材机耗量地区
     * @return 结果
     */
    @Override
    public int insertCusLinkSubpkConsumeAddress(CusLinkSubpkConsumeAddress cusLinkSubpkConsumeAddress)
    {
            return cusLinkSubpkConsumeAddressMapper.insert(cusLinkSubpkConsumeAddress);
    }

    /**
     * 修改标准费用项材机耗量地区
     *
     * @param cusLinkSubpkConsumeAddress 标准费用项材机耗量地区
     * @return 结果
     */
    @Override
    public int updateCusLinkSubpkConsumeAddress(CusLinkSubpkConsumeAddress cusLinkSubpkConsumeAddress)
    {
        return cusLinkSubpkConsumeAddressMapper.updateById(cusLinkSubpkConsumeAddress);
    }

    /**
     * 批量删除标准费用项材机耗量地区
     *
     * @param ids 需要删除的标准费用项材机耗量地区主键
     * @return 结果
     */
    @Override
    public int deleteCusLinkSubpkConsumeAddressByIds(String[] ids)
    {
        return cusLinkSubpkConsumeAddressMapper.deleteCusLinkSubpkConsumeAddressByIds(ids);
    }

    /**
     * 删除标准费用项材机耗量地区信息
     *
     * @param id 标准费用项材机耗量地区主键
     * @return 结果
     */
    @Override
    public int deleteCusLinkSubpkConsumeAddressById(String id)
    {
        return cusLinkSubpkConsumeAddressMapper.deleteCusLinkSubpkConsumeAddressById(id);
    }

    @Override
    public int updateTime(String id,Long companyId) {
        UpdateWrapper<CusLinkSubpkConsumeAddress> wrapper = new UpdateWrapper<>();
        wrapper.eq("id",id);
        wrapper.eq("company_id",companyId);
        wrapper.set("update_time", DateUtils.getNowDate());

        return cusLinkSubpkConsumeAddressMapper.update(null,wrapper);
    }
}
